package cn.edu.hpu.jie.services;

import cn.edu.hpu.jie.dao.ActiveDao;
import cn.edu.hpu.jie.entity.Active;
import cn.edu.hpu.jie.entity.Log;
import cn.edu.hpu.jie.util.DateUtil;

public class ActiveService {
	private ActiveDao dao = new ActiveDao();

	public Active getActiveByType(int type) {
		return dao.getActiveByType(type);
	}

	public int insertActive(Active a, String path, int loginid) {
		a.setSites("test");
		int eventid = dao.insertActive(a);
		
		LogService ls = new LogService();
		Log l = new Log();
		l.setDesc("添加了活动介绍");
		l.setEventid(eventid);
		l.setLoginid(loginid);
		l.setTime(DateUtil.getNow());
		return ls.insertLog(l);
	}

	public int editActive(Active active, String path, int loginid) {
		active.setSites("test");
		dao.updateActiveByType(active);
		
		LogService ls = new LogService();
		Log l = new Log();
		l.setDesc("修改了活动介绍");
		l.setEventid(active.getId());
		l.setLoginid(loginid);
		l.setTime(DateUtil.getNow());
		return ls.insertLog(l);
	}
	
}
